<?php
class Admin_Controller_Project extends Admin_Controller_Base{
    public function init(){
        parent::init();
    }

    public function actionCheckCategory(){
        $model_project = MONK::getSingleton('Admin_Model_Project');
        $categorys = $model_project->_project_category;
        $this->assign('categorys',$categorys);
        return $this->render();
    }

    public function actionAdd(){
        $this->_setType(array('pid'=>PARAM_STRING,'sid'=>PARAM_STRING));
        $pid = $this->_get('pid');
        $sid = $this->_get('sid');
        if(empty($pid)) return $this->redirect(MONK::_url('*/CheckCategory'));
        $model_project = MONK::getSingleton('Admin_Model_Project');
        //项目分类
        $category_name = '';
        $categorys = $model_project->_project_category;
        $category_name .= $categorys[$pid]['title'];
        if(!empty($sid)) $category_name .= ' - '.$categorys[$pid]['sub'][$sid]['title'];
        $this->assign('category_name',$category_name);
        //项目阶段
        $stages = $model_project->_project_stage;
        $this->assign('stages',$stages);
        //融资方式
        $modes = $model_project->_project_mode;
        $this->assign('modes',$modes);
        //抵押物
        $pledges = $model_project->_project_pledge;
        $this->assign('pledges',$pledges);
        //页面加载选择
        $class_id = $pid.(!empty($sid)?'_'.$sid:'');
        $this->assign('class_id',$class_id);

        return $this->render();
    }

    public function actionAdd_POST(){
        //不作过滤，有一定风险
        $mainData = array();
        $optionData = array();
        $this->_setType(array('project_category'=>PARAM_STRING,'project_content'=>array('func'=>PARAM_STRING,'argv'=>PARAM_TEXT)),'post');
        $project_content = $this->_post('project_content');
        $mainData['project_category'] = $this->_post('project_category');
        $this->_setType($this->_project_category_validate[$mainData['project_category']],'post');
        foreach($this->_project_category_validate[$mainData['project_category']] as $k=>$v){
            $optionData[$k] = $this->_post($k);
        }
        dump($_POST);
        dump($_FILES);
    }

    public function actionList(){
        return $this->render();
    }

    private $_project_category_validate = array(
        'p10_s110'  => array(
            'project_financing_sum' => PARAM_UINT,
            'project_cycle'         => PARAM_UINT,
            'project_rate'          => PARAM_FLOAT,
            'project_financing_total' => PARAM_UINT,
            'project_stage'         => PARAM_UINT,
            'project_financing_mode'=> PARAM_UINT,
            'project_appraisement'  => PARAM_UINT,
        ),
        'p10_s120'  => array(
            'project_financing_sum' => PARAM_UINT,
            'project_cycle'         => PARAM_UINT,
            'project_rate'          => PARAM_FLOAT,
            'project_financing_total' => PARAM_UINT,
            'project_stage'         => PARAM_UINT,
            'project_financing_mode'=> PARAM_UINT,
            'project_appraisement'  => PARAM_UINT,
        ),
        'p10_s130'  => array(
            'project_financing_sum' => PARAM_UINT,
            'project_cycle'         => PARAM_UINT,
            'project_rate'          => PARAM_FLOAT,
            'project_financing_total' => PARAM_UINT,
            'project_stage'         => PARAM_UINT,
            'project_financing_mode'=> PARAM_UINT,
            'project_deadline'      => PARAM_UINT,
            'project_pledge'        => array('func'=>PARAM_ARRAY,'argv'=>PARAM_ARR_INT),
            'project_assure_info'   => array('func'=>PARAM_STRING,'argv'=>PARAM_TEXT),
            'project_repayment_mode'=> PARAM_STRING,
        ),
        'p10_s140'  => array(
            'project_financing_sum' => PARAM_UINT,
            'project_cycle'         => PARAM_UINT,
            'project_rate'          => PARAM_FLOAT,
            'project_financing_total' => PARAM_UINT,
            'project_stage'         => PARAM_UINT,
            'project_financing_mode'=> PARAM_UINT,
            'project_requirement'   => PARAM_STRING,
        ),
        'p10_s210'  => array(
            'project_financing_attr'    => PARAM_STRING,
            'project_appraisement'      => PARAM_UINT,
            'project_financing_status'  => PARAM_BOOL,
            'project_financing_sum'     => PARAM_UINT,
            'project_transfer_form'     => PARAM_UINT,
            'project_transaction_mode'  => PARAM_STRING,
            //分界
            'project_company_name'      => PARAM_STRING,
            'project_transfer_lot'      => PARAM_STRING,
            'project_listed_price'      => PARAM_UINT,
            'project_primary_business'  => PARAM_STRING,
            'project_qualification'     => PARAM_STRING,
        ),
        'p20_s215'  => array(
            'project_financing_attr'    => PARAM_STRING,
            'project_appraisement'      => PARAM_UINT,
            'project_financing_status'  => PARAM_BOOL,
            'project_financing_sum'     => PARAM_UINT,
            'project_transfer_form'     => PARAM_UINT,
            'project_transaction_mode'  => PARAM_STRING,
            //分界
            'project_prospecting'       => PARAM_STRING,
            'project_mining'            => PARAM_STRING,
        ),
        'p20_s220'  => array(
            'project_financing_attr'    => PARAM_STRING,
            'project_appraisement'      => PARAM_UINT,
            'project_financing_status'  => PARAM_BOOL,
            'project_financing_sum'     => PARAM_UINT,
            'project_transfer_form'     => PARAM_UINT,
            'project_transaction_mode'  => PARAM_STRING,
            //分界
            'project_address'           => PARAM_STRING,
            'project_usetimes'          => PARAM_UINT,
            'project_house_type'        => PARAM_UINT,
            'project_house_number'      => PARAM_STRING,
            'project_house_acreage'     => PARAM_UINT,
            'project_house_environment' => PARAM_STRING,
            'project_house_facilities'  => PARAM_STRING,
            'project_house_operate'     => PARAM_STRING,
        ),
        'p20_s225'  => array(
            'project_financing_attr'    => PARAM_STRING,
            'project_appraisement'      => PARAM_UINT,
            'project_financing_status'  => PARAM_BOOL,
            'project_financing_sum'     => PARAM_UINT,
            'project_transfer_form'     => PARAM_UINT,
            'project_transaction_mode'  => PARAM_STRING,
            //分界
            'project_land_number'       => PARAM_STRING,
            'project_land_use'          => PARAM_STRING,
            'project_land_acreage'      => PARAM_UINT,
            'project_land_address'      => PARAM_STRING,
            'project_land_type'         => PARAM_STRING,
            'project_land_plan'         => PARAM_STRING,
            'project_land_now'          => PARAM_STRING,
        ),
        'p20_s230'  => array(
            'project_financing_attr'    => PARAM_STRING,
            'project_appraisement'      => PARAM_UINT,
            'project_financing_status'  => PARAM_BOOL,
            'project_financing_sum'     => PARAM_UINT,
            'project_transfer_form'     => PARAM_UINT,
            'project_transaction_mode'  => PARAM_STRING,
            //分界
            'project_debt_value'        => PARAM_UINT,
            'project_debt_mode'         => PARAM_UINT,
        ),
        'p20_s235'  => array(
            'project_financing_attr'    => PARAM_STRING,
            'project_appraisement'      => PARAM_UINT,
            'project_financing_status'  => PARAM_BOOL,
            'project_financing_sum'     => PARAM_UINT,
            'project_transfer_form'     => PARAM_UINT,
            'project_transaction_mode'  => PARAM_STRING,
            //分界
            'project_forest_number'     => PARAM_STRING,
            'project_forest_usetimes'   => PARAM_UINT,
            'project_forest_acreage'    => PARAM_UINT,
        ),
        'p20_s240'  => array(
            'project_financing_attr'    => PARAM_STRING,
            'project_appraisement'      => PARAM_UINT,
            'project_financing_status'  => PARAM_BOOL,
            'project_financing_sum'     => PARAM_UINT,
            'project_transfer_form'     => PARAM_UINT,
            'project_transaction_mode'  => PARAM_STRING,
            //分界
            'project_device_num'        => PARAM_STRING,
            'project_device_format'     => PARAM_STRING,
        ),
        'p20_s245'  => array(
            'project_financing_attr'    => PARAM_STRING,
            'project_appraisement'      => PARAM_UINT,
            'project_financing_status'  => PARAM_BOOL,
            'project_financing_sum'     => PARAM_UINT,
            'project_transfer_form'     => PARAM_UINT,
            'project_transaction_mode'  => PARAM_STRING,
            //分界
            'project_car_type'          => PARAM_STRING,
            'project_car_course'        => PARAM_UINT,
            'project_car_cardtime'      => PARAM_DATETIME,
        ),
        'p20_s250'  => array(
            'project_financing_attr'    => PARAM_STRING,
            'project_appraisement'      => PARAM_UINT,
            'project_financing_status'  => PARAM_BOOL,
            'project_financing_sum'     => PARAM_UINT,
            'project_transfer_form'     => PARAM_UINT,
            'project_transaction_mode'  => PARAM_STRING,
            //分界
            'project_bond_type'         => PARAM_STRING,
            'project_bond_sum'          => PARAM_STRING,
        ),
        'p20_s255'  => array(
            'project_financing_attr'    => PARAM_STRING,
            'project_appraisement'      => PARAM_UINT,
            'project_financing_status'  => PARAM_BOOL,
            'project_financing_sum'     => PARAM_UINT,
            'project_transfer_form'     => PARAM_UINT,
            'project_transaction_mode'  => PARAM_STRING,
            //分界
            'project_chop_number'       => PARAM_STRING,
        ),
        'p20_s260'  => array(
            'project_financing_attr'    => PARAM_STRING,
            'project_appraisement'      => PARAM_UINT,
            'project_financing_status'  => PARAM_BOOL,
            'project_financing_sum'     => PARAM_UINT,
            'project_transfer_form'     => PARAM_UINT,
            'project_transaction_mode'  => PARAM_STRING,
            //分界
            'project_patent_number'     => PARAM_STRING,
        ),
        'p20_s265'  => array(
            'project_financing_attr'    => PARAM_STRING,
            'project_appraisement'      => PARAM_UINT,
            'project_financing_status'  => PARAM_BOOL,
            'project_financing_sum'     => PARAM_UINT,
            'project_transfer_form'     => PARAM_UINT,
            'project_transaction_mode'  => PARAM_STRING,
            //分界
            'project_domain_number'     => PARAM_STRING,
        ),
        'p20_s270'  => array(
            'project_financing_attr'    => PARAM_STRING,
            'project_appraisement'      => PARAM_UINT,
            'project_financing_status'  => PARAM_BOOL,
            'project_financing_sum'     => PARAM_UINT,
            'project_transfer_form'     => PARAM_UINT,
            'project_transaction_mode'  => PARAM_STRING,
            //分界
        ),
        'p30_s310'  => array(
            'project_affiance_company'  => PARAM_UINT,
            'project_affiance_bearing'  => PARAM_UINT,
            'project_affiance_class'    => PARAM_UINT,
            'project_cycle'             => PARAM_UINT,
            'project_rate'              => PARAM_UINT,
            'project_financing_sum'     => PARAM_UINT,
        ),
        'p30_s320'  => array(
            'project_financing_sum'     => PARAM_UINT,
            'project_bank_sum'          => PARAM_UINT,
            'project_bank_name'         => PARAM_STRING,
            'project_rate'              => PARAM_UINT,
            'project_bank_hold'         => PARAM_BOOL,
        ),
        'p30_s330'  => array(
            'project_private_place'     => PARAM_UINT,
            'project_cycle'             => PARAM_UINT,
            'project_rate'              => PARAM_UINT,
        ),
        'p30_s340'  => array(
            'project_cycle'             => PARAM_UINT,
            'project_rate'              => PARAM_UINT,
            'project_sell_organization' => PARAM_STRING,
        ),
        'p40'  => array(
            'project_financing_sum'     => PARAM_UINT,
            'project_rate'              => PARAM_UINT,
            'project_cycle'             => PARAM_UINT,
            'project_financing_form'    => PARAM_STRING,
            'project_financing_body'    => PARAM_STRING,
        ),
        'p50'  => array(
            'project_gov_policy'        => PARAM_STRING,
            'project_gov_climate'       => PARAM_STRING,
        ),
    );

}
